package com.cadre.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cadre.common.utils.oldutil.PageUtils;
import com.cadre.system.domain.officer.A01;
import com.cadre.system.domain.officer.BatchconferenceEntity;
import com.cadre.system.mapper.BatchconferenceMapper;
import com.cadre.system.service.A01Service;
import com.cadre.system.service.Batch_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("Batch_Service")
public class Batch_ServiceImpl extends ServiceImpl<BatchconferenceMapper, BatchconferenceEntity> implements Batch_Service {
    @Autowired
    A01Service a01Service;

    @Autowired
    private BatchconferenceMapper batchconferenceMapper;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        List<BatchconferenceEntity> list = batchconferenceMapper.getBatchServPages(params);
        int total = batchconferenceMapper.getBatchServPagesCount(params);
        Page page = new Page();
        page.setRecords(list);
        page.setCurrent(Integer.parseInt(params.get("page").toString()));
        page.setSize(Integer.parseInt(params.get("limit").toString()));
        page.setTotal(total);
        //（已调整完毕）TODO: 这里需要将上面的sql查询移动到xml文件中
        return new PageUtils(page);
    }

    @Override
    public List<BatchconferenceEntity> getAllList() {
        //（已调整完毕）TODO: 将西面的sql移动到xml中
        return this.baseMapper.selectList(new LambdaQueryWrapper<BatchconferenceEntity>().
                select(BatchconferenceEntity::getFlowid,BatchconferenceEntity::getName).orderByDesc(BatchconferenceEntity::getCreatetime));
    }

    @Override
    public List<A01> getListA01ByKey(String[] keys) {
        //（已调整完毕）todo: 将下面的sql移动到xml中
        return this.a01Service.getBaseMapper().selectList(new LambdaQueryWrapper<A01>().select(A01::getFlowid,A01::getA0101,A01::getA0183).
                in(A01::getA0101, keys).or().in(A01::getA0102, keys));
    }
}
